# from typing import Optional, Type
# from uuid import UUID
# from fastapi_users.db import BaseUserDatabase
# from db.models.users import User, UserDocument, UserCreate
# from beanie import PydanticObjectId
#
#
# class CustomUserDatabase(BaseUserDatabase[User, UUID]):
#     async def get(self, id: UUID) -> Optional[User]:
#         user_doc = await UserDocument.find_one({"user_id": str(id)})
#         return self._document_to_user(user_doc) if user_doc else None
#
#     # async def get_by_email(self, email: str) -> Optional[User]:
#     #     user_doc = await UserDocument.find_one({"email": email})
#     #     return self._document_to_user(user_doc) if user_doc else None
#     async def get_by_username(self, username: str) -> Optional[User]:
#         user_doc = await UserDocument.find_one({"username": username})
#         return self._document_to_user(user_doc) if user_doc else None
#
#     async def create(self, user: dict) -> User:
#
#         user_doc = UserDocument(
#             # email=user.email,
#             username=user.get("username"),
#             hashed_password=user.get("hashed_password"),
#             # is_active=user.is_active,
#             # is_superuser=user.is_superuser,
#             # is_verified=user.is_verified,
#         )
#         await user_doc.insert()
#         return self._document_to_user(user_doc) if user_doc else None
#
#
#
#     # async def update(self, user: User) -> User:
#     #     user_doc = await UserDocument.find_one({"id": PydanticObjectId(str(user.id))})
#     #     if user_doc:
#     #         user_doc.email = user.email
#     #         user_doc.hashed_password = user.hashed_password
#     #         user_doc.is_active = user.is_active
#     #         user_doc.is_superuser = user.is_superuser
#     #         user_doc.is_verified = user.is_verified
#     #         await user_doc.save()
#     #     return self._document_to_user(user_doc) if user_doc else None
#
#     async def delete(self, user: User) -> None:
#         user_doc = await UserDocument.find_one({"id": PydanticObjectId(str(user.id))})
#         if user_doc:
#             await user_doc.delete()
#     def _document_to_user(self, user_doc: UserDocument) -> User:
#         return User(
#             id=user_doc.user_id,
#             username=user_doc.username,
#             hashed_password=user_doc.hashed_password,
#             is_active=user_doc.is_active,
#             is_superuser=user_doc.is_superuser,
#             is_verified=user_doc.is_verified
#         )
#
#
# async def get_user_db():
#     yield CustomUserDatabase()